<template>
 <div>
    <table border="1">
        <tr>
            <td>名称</td>
            <td>价格</td>
        </tr>
        <tr v-for=" (i,index) in data" :class="{on:index%2!=0, off:index%2==0}">
            <td>{{i.name}}</td>
            <td>{{i.price}}</td>
        </tr>
    </table>
 </div>
</template>

<script>
export default {
 data() {
  return {
    data:'',
  }
  
 },
 mounted() {
    this.axios({
        url:'http://127.0.0.1:8000/goods/',
        method:'get',
    }).then(res=>{
        this.data = res.data.data
    })
 },

 components: {

 },
 
}
</script>

<style >
    .on{
        background: red;
    }
    .off{
        background: green;
    }
</style>

